﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IPageable<DR.WebUI.Models.Project.ViewProject>>" %>
<%@ Import Namespace="DR.WebUI.Models.Project" %>
<%@ Import Namespace="DR.WebUI.Models.Common" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Projects
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server" style="min-width:1000">

    <h3>Projects</h3>

    <%Html.EnableClientValidation(); %>
    <div>
        <form method="post" action="SetupProjectFilter">
          <div>

            <div style="border-right: 1px solid #e2e2e2; float: left; margin-right: 10px; margin-top: 5px;">
                <%if (Page.User.IsInRole("TopManager")) 
                {%>
                    <a href="/Project/Create" class="linkAddReport">Add Project</a>
                <%}%>
            </div> 

            <table>
                <tr>
                    <td><b>Project Name</b></td>
                    <td><b>Left Date</b></td>
                    <td><b>Right Date</b></td>
                    <td><b>Status</b></td>
                    <td rowspan="2" style="vertical-align:bottom">
                        <input type="submit" name="filterButton" value="Apply" id="Apply"/>
                        <input type="submit" name="filterButton" value="Reset" id="Reset"/>
                    </td>
                </tr>
                <tr>
                    <% ProjectFilter filter = (ProjectFilter)ViewData["ProjectFilter"]; %>
                    <td>                    
                        <%:Html.TextBox("ProjectName", null, new { @class = "modalTextBox" })%>
                        <br />
                        <%:Html.ValidationMessageFor(validation => filter.ProjectName)%>
                    </td>
                    <td>
                        <input type="text" id="Date" name="DateLeft" value="<%=filter.DateLeft %>" class="miniTextBox" />
                    </td>
                    <td>
                        <input type="text" id="Date1" name="DateRight" value="<%=filter.DateRight %>" class="miniTextBox" />
                    </td>
                    <td>
                        <% foreach (EnumItem item in (IList<EnumItem>)ViewData["ProjectStatuses"]) %>
                        <% { %>
                            <input type="checkbox" name="statuses" value="<%: item.StatusID %>" <%: filter.SelectedProjectStatuses.Contains(item.StatusID) ? "checked='checked'" : "" %> />
                            <%: item.Text %>
                        <% } %>
                    </td>
                </tr>   
            </table> 
          </div>
        </form>
    </div>
    
    <br />
    <div id="tableStyle">
        <table style="width:100%;">
            <thead>
                <tr>
                    <th style="width:5%;">ID</th>
                    <th style="width:20%; min-width:140px">Title</th>
                    <th style="width:20%; min-width:140px">Description</th>
                    <th style="width:10%; min-width:140px">Date Create</th>
                    <th style="width:10%; min-width:140px">Start Date</th>
                    <th style="width:10%; min-width:140px">Finish Date</th>
                    <th style="width:10%; min-width:140px" >Status</th>
                    <th style="width:10%; min-width:90px; max-width:90px;"></th>
                </tr>
            </thead>
           <%if (Model.Page.Count() == 0) %>
           <%{%>
           <tbody>
                <tr>
                    <td colspan="8" class="nodata">No Data</td>
                </tr>
           </tbody>
           <%}%>
           <%else %>
           <%{%>
            <tbody>            
                <%
                 foreach (var r in Model.Page)%>
                <%{%>
                    <tr>
                        <td><%:r.ID%></td>
                        <td style="word-wrap:break-word;max-width:310px;min-width:150px;"><%:r.Title%></td>
                        <td style="word-wrap:break-word;max-width:200px;min-width:150px;"><%:r.Description%></td> 
                        <td><%:r.DateCreate%></td>
                        <td><%:r.StartDate%></td>
                        <td><%:r.FinishDate%></td>
                        <td><%:r.Status%></td>
                        <td>
                            <a href="/Project/ViewProjectDetails?projectid=<%:r.ID%>" class="viewProject" title="View Details"></a>
                            <div>
                                <%: Html.Hidden("ProjectID_" + r.ID, r.ID, new {@class = "project-id"}) %>
                                <div class="delete" title="Delete"></div>
                            </div>
                            <a href="/project/edit/<%:r.ID %>" class="editProject" title="Edit"/>
                        </td>
                    </tr>        
                <% } %>
            </tbody>
            <% } %>
        </table>
    </div>
    
    <div>
        <%= Html.Pagination() %>
    </div>

</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="headPlaceHolder" runat="server">    

    <script type="text/javascript" src="<%= Url.Content("~/Scripts/jquery-1.4.4.min.js")%>"></script>
    <script type="text/javascript" src="<%= Url.Content("~/Scripts/jquery-ui-1.8.7.custom.min.js")%>"></script>

    <link type="text/css" href="/Content/jquery/jquery-ui-1.8.7.custom.css" rel="stylesheet" />
    <link type="text/css" href="/Content/css/Awesome.css" rel="stylesheet"  />

    <script type="text/javascript" src="<%= Url.Content("~/Scripts/jquery.form.js")%>"></script>
    <script type="text/javascript" src="<%= Url.Content("~/Scripts/Awesome.js")%>" ></script>
    <script type="text/javascript" src="<%= Url.Content("~/Scripts/Project/delete-project.js")%>" ></script>
    <script type="text/javascript" language="javascript">
        $(function () {
            $("#Date").datepicker();
            $("#Date1").datepicker();
            $("#add").button();
            $("#cancel").button();
        });
	</script>

</asp:Content>